package test4;
// 字符串查找
public class TestDemo2 {

    public static void main(String[] args) {
        String str="ababcabcd";
        System.out.println(str.endsWith("cd"));//true
        System.out.println(str.endsWith("cde"));//false
    }

    public static void main4(String[] args) {
        String str="ababcabcd";
        String tmp="abc";
        System.out.println(str.startsWith("ab"));//true
        System.out.println(str.startsWith("c",4));//true

    }

    public static void main3(String[] args) {
        String str="ababcabcd";
        String tmp="abc";
        System.out.println(str.lastIndexOf(tmp));//5


    }
    public static void main2(String[] args) {
        String str="ababcabcd";
        String tmp="abc";
        int ret=str.indexOf(tmp);
        System.out.println(ret);//2
    }

    public static void main1(String[] args) {
        String str="ababcabcd";
        String tmp="abc";
        boolean flg=str.contains(tmp);
        System.out.println(flg);//true
    }
}
